#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int brr[N];
int n, m;
bool fun(int n)
{
	int l = 0;
	int r = m - 1;
	/*while (l < r) {
		int mid = (l + r) >> 1;
		if (brr[mid] >= n) {
			r = mid;
		}
		else {
			l = mid + 1;;
		}
	}
	if (brr[l] == n) {	
		return 1;
	}
	return 0;*/
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (brr[mid] < n) {
			l = mid + 1;
		}
		else if (brr[mid] > n) {
			r = mid - 1;
		}
		else {
			return 1;
		}
	}
	return 0;
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> brr[i];
	}
	sort(brr, brr + m);
	for (int i = 0; i < n; i++) {
		if (fun(arr[i])) {
			cout << arr[i] << " ";
		}
	}
	return 0;
}